<template>
  <div class="app-container">
    <el-form :inline="true" ref="ruleForm" :model="formInline" class="demo-form-inline">
      <el-form-item prop="time" label="提交时间">
        <el-date-picker
          v-model="formInline.time"
          type="datetimerange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          :default-time="['00:00:00', '23:59:59']"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd HH:mm:ss"
          :picker-options="pickerDayStep">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="提交人" prop="applicant">
        <el-select v-model="formInline.applicant" placeholder="请选择提交人">
          <el-option
            v-for="item in auditApplierList"
            :label="item"
            :key="item"
            :value="item"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="审核人" prop="auditor">
        <el-select v-model="formInline.auditor" placeholder="请选择审核人">
          <el-option
            v-for="item in auditAuditorList"
            :label="item"
            :key="item"
            :value="item"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="formInline.status" placeholder="请选择状态">
          <el-option
            v-for="item in consts.REORDER_AUDIT_STATUS"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="存款类型" prop="limitType">
        <el-select
          v-model="formInline.limitType"
          placeholder="请存款类型"
        >
          <el-option
            v-for="item in payEnum.DEPOSIT_TYPE"
            :label="item.title"
            :key="item.value"
            :value="item.value"
            v-show="dataRoleCheck(item.permission)"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item prop="username" label="账户名">
          <el-input @keyup.enter.native="$emit('on-filter',formInline)" v-model="formInline.username" placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item prop="telephone" label="手机号">
          <el-input @keyup.enter.native="$emit('on-filter',formInline)" v-model="formInline.telephone" placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item prop="thirdOrderId" label="第三方单号">
          <el-input @keyup.enter.native="$emit('on-filter',formInline)" v-model="formInline.thirdOrderId" placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item prop="reallyName" label="姓名">
          <el-input @keyup.enter.native="$emit('on-filter',formInline)" v-model="formInline.reallyName" placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item prop="orderId" label="充值单号">
          <el-input @keyup.enter.native="$emit('on-filter',formInline)" v-model="formInline.orderId" placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item label="账户类型" prop="userType">
        <el-select
          v-model="formInline.userType"
          placeholder="请选择账户类型"
        >
          <el-option
            v-for="item in payEnum.USER_TYPE"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-button
        class="filter-item"
        type="primary"
        icon="el-icon-search"
        @click="$emit('on-filter', formInline)"
      >
        搜索
      </el-button>
      <el-button @click="selfResetForm('ruleForm')">重置</el-button>
    </el-form>
  </div>

</template>

<script>

// services
import { getRechargeManageAuditor, getRechargeManageApplicant } from '@/services/api/recharge';

// mixins
import { form, grid, pickerOption } from '@/build';

export default {
  name: 'form-filter',
  mixins: [form, grid, pickerOption],
  data() {
    return {
      auditApplierList: [],
      auditAuditorList: [],
      formInline: {
        time: [moment().format('YYYY-MM-DD 00:00:00'), moment().format('YYYY-MM-DD 23:59:59')],
        applicant: undefined,
        auditor: undefined,
        status: undefined,
        username: undefined,
        telephone: undefined,
        thirdOrderId: undefined,
        reallyName: undefined,
        orderId: undefined,
        limitType: -1,
        userType: -1,
      },
    };
  },
  methods: {
    selfResetForm(formName) {
      this.resetForm(formName);
      this.$parent.getAll();
    },
  },
  mounted() {
    this.bindGet(getRechargeManageApplicant, 'auditApplierList', {
    });
    this.bindGet(getRechargeManageAuditor, 'auditAuditorList', {});
    this.getAll();
  },
};
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 120px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
